package com.quectel.cms.controller.propertybill;


import cn.hutool.core.lang.func.LambdaUtil;
import com.quectel.cms.controller.BaseController;
import com.quectel.cms.util.SessionHolder;
import com.quectel.constant.core.propertybill.PropertyBillConstants;
import com.quectel.constant.core.propertybill.PropertyChargeableConstant;
import com.quectel.constant.global.SystemConstants;
import com.quectel.constant.global.annotation.RequirePermissions;
import com.quectel.core.module.propertybill.dto.PropertyChargeableListBindingDto;
import com.quectel.core.module.propertybill.dto.PropertyChargeableListDto;
import com.quectel.core.module.propertybill.dto.PropertyChargeableListDueDateDto;
import com.quectel.core.module.propertybill.dto.PropertyRoomChargeableListDueDateDto;
import com.quectel.core.module.propertybill.service.PropertyChargeableListBindingService;
import com.quectel.core.module.propertybill.service.PropertyChargeableListDueDateService;
import com.quectel.core.module.propertybill.service.PropertyChargeableListService;
import com.quectel.core.module.village.dto.VillageBuildingDto;
import com.quectel.core.module.village.dto.VillageDto;
import com.quectel.core.module.village.dto.VillageFloorDto;
import com.quectel.core.module.village.dto.VillageRoomDto;
import com.quectel.core.module.village.service.VillageBuildingService;
import com.quectel.core.module.village.service.VillageFloorService;
import com.quectel.core.module.village.service.VillageRoomService;
import com.quectel.core.module.village.service.VillageService;
import com.quectel.util.common.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/04/03 11:03
 */
@RestController
@RequestMapping("propertyRoomChargeableListDueDate")
@Tag(name = "PropertyRoomChargeableListDueDateController", description = "小区房间收费标准逾期时间相关api")
public class PropertyRoomChargeableListDueDateController extends BaseController {

    private static final String DUE_DATE_EXAMPLE = "（逾期日期，示例2023-01-01）";

    @DubboReference
    private VillageService villageService;
    @DubboReference
    private VillageBuildingService villageBuildingService;
    @DubboReference
    private VillageFloorService villageFloorService;
    @DubboReference
    private VillageRoomService villageRoomService;
    @DubboReference
    private PropertyChargeableListService propertyChargeableListService;
    @DubboReference
    private PropertyChargeableListBindingService propertyChargeableListBindingService;
    @DubboReference
    private PropertyChargeableListDueDateService propertyChargeableListDueDateService;


    @PostMapping("importExcel")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:importExcel")
    @Operation(summary = "房间收费标准逾期时间导入")
    public Response<Object> importExcel(
            MultipartHttpServletRequest request
    ) {
        final Long tenantId = SessionHolder.getSysUser().getTenantId();
        Date currentDate = new Date();
        int totalCount = 0;
        int successCount = 0;

        //导入数据
        List<PropertyChargeableListDueDateDto> propertyChargeableListDueDateDtos = new ArrayList<>();
        Iterator<String> fileNames = request.getFileNames();
        while (fileNames.hasNext()) {
            String next = fileNames.next();
            List<MultipartFile> files = request.getFiles(next);
            for (MultipartFile file : files) {
                try {
                    //从第一行开始 表头上面有标准对应的名称 （过期日期）需要去除
                    List<Map<Integer, String>> analysis = POIUtils.analysis(file.getInputStream(), 0, 0);

                    //数据量是总数据量-1
                    totalCount += analysis.size() - 1;

                    //记录表头
                    Map<Integer, String> titleMap = analysis.get(0);

                    //去除第一个表头
                    analysis.remove(0);

                    Map<String, List<Map<Integer, String>>> groupByVillageName = analysis.stream().collect(Collectors.groupingBy(o -> o.get(0)));

                    for (String villageName : groupByVillageName.keySet()) {
                        VillageDto villageDto = villageService.selectCacheByName(tenantId, villageName);
                        if (villageDto == null) {
                            continue;
                        }

                        List<Map<Integer, String>> maps = groupByVillageName.get(villageName);

                        //查询适用于该房间的收费标准
                        List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByTenantAndVillage(villageDto.getTenantId(), villageDto.getId());
                        if (CollectionUtils.isEmpty(propertyChargeableListDtos)) {
                            continue;
                        }
                        Map<String, PropertyChargeableListDto> collect = propertyChargeableListDtos.stream().collect(Collectors.toMap(PropertyChargeableListDto::getName, Function.identity(), (key1, key2) -> key2));


                        for (Map<Integer, String> row : maps) {
                            String buildingName = row.get(1);
                            String floorNo = row.get(2);
                            String roomName = row.get(3);

                            VillageBuildingDto villageBuildingDto = villageBuildingService.selectByName(villageDto.getId(), buildingName);
                            if (villageBuildingDto == null) {
                                continue;
                            }

                            VillageFloorDto villageFloorDto = villageFloorService.selectByFloorNo(villageBuildingDto.getId(), Integer.valueOf(floorNo));
                            if (villageFloorDto == null) {
                                continue;
                            }

                            VillageRoomDto villageRoomDto = villageRoomService.selectByName(villageFloorDto.getId(), roomName);
                            if (villageRoomDto == null) {
                                continue;
                            }
                            if (row.size() <= 4) {
                                continue;
                            }

                            //多个收费标准
                            //从第五个开始
                            for (int i = 4; i < row.size(); i++) {
                                if (StringUtils.isBlank(row.get(i))) {
                                    continue;
                                }

                                String s = titleMap.get(i).replace(DUE_DATE_EXAMPLE, "");
                                PropertyChargeableListDto propertyChargeableListDto = collect.get(s);
                                if (propertyChargeableListDto == null) {
                                    continue;
                                }

                                Map<String, Object> params = new HashMap<>();
                                params.put(LambdaUtil.getFieldName(PropertyChargeableListBindingDto::getChargeableListId), propertyChargeableListDto.getId());
                                params.put(LambdaUtil.getFieldName(PropertyChargeableListBindingDto::getBindingType), PropertyChargeableConstant.SourceType.VILLAGE.getType());
                                params.put(LambdaUtil.getFieldName(PropertyChargeableListBindingDto::getBindingId), villageRoomDto.getBuildingId());
                                List<PropertyChargeableListBindingDto> propertyChargeableListBindingDtos = propertyChargeableListBindingService.queryList(params);
                                //如果该楼栋无法适用于该标准,则无法导入
                                if (CollectionUtils.isEmpty(propertyChargeableListBindingDtos)) {
                                    continue;
                                }

                                PropertyChargeableListDueDateDto propertyChargeableListDueDateDto = new PropertyChargeableListDueDateDto();
                                propertyChargeableListDueDateDto.setTenantId(villageRoomDto.getTenantId());
                                propertyChargeableListDueDateDto.setVillageId(villageRoomDto.getVillageId());
                                propertyChargeableListDueDateDto.setRoomId(villageRoomDto.getId());
                                propertyChargeableListDueDateDto.setChargeableListId(propertyChargeableListDto.getId());

                                String dueDate = row.get(i);
                                propertyChargeableListDueDateDto.setDueDate(DateUtils.parse(dueDate, DateUtils.FormatType.SIMPLE));
                                propertyChargeableListDueDateDto.setImportTime(currentDate);

                                propertyChargeableListDueDateDtos.add(propertyChargeableListDueDateDto);
                            }
                        }

                    }
                } catch (Exception e) {
                    logger.error("解析账单日期数据出错", e);
                }
            }
        }
        if (CollectionUtils.isNotEmpty(propertyChargeableListDueDateDtos)) {
            propertyChargeableListDueDateDtos.forEach(
                    dto -> {
                        PropertyChargeableListDueDateDto propertyChargeableListDueDateDto = propertyChargeableListDueDateService.selectByRoomInfoAndListId(dto.getTenantId(), dto.getVillageId(), dto.getRoomId(), dto.getChargeableListId());
                        if (propertyChargeableListDueDateDto != null) {
                            dto.setId(propertyChargeableListDueDateDto.getId());
                            propertyChargeableListDueDateService.updateById(dto);
                        } else {
                            propertyChargeableListDueDateService.save(dto);
                        }
                    }
            );
        }
        successCount = propertyChargeableListDueDateDtos.size();
        return Response.error("导入数据完成 总数:" + totalCount + " 成功数:" + successCount);
    }


    /**
     * 导出收费标准过期日期导入模板
     * 选择小区或者楼栋
     */
    @GetMapping("exportExcelTemplate")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:exportExcel")
    @Operation(summary = "导出收费标准过期日期导入模板")
    public void exportExcel(@RequestParam Map<String, Object> params,
                            @Parameter(description = "小区id") @RequestParam(required = false) Long villageId,
                            @Parameter(description = "楼栋id") @RequestParam(required = false) Long buildingId,
                            HttpServletResponse hresp) {

        super.fillAuthorityData(params);

        if (villageId == null && buildingId == null) {
            return;
        }

        //所属小区 所属楼栋 所属楼层 所属房间
        List<String> headers = new ArrayList<>();
        headers.add("所属小区");
        headers.add("所属楼栋");
        headers.add("房屋实际层高(数字)");
        headers.add("房间名称");

        params.put(LambdaUtil.getFieldName(PropertyChargeableListDto::getStatus), SystemConstants.NORMAL);

        VillageDto villageDto = null;
        VillageBuildingDto villageBuildingDto = null;

        if (buildingId == null) {
            //查询所有的收费标准
            List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByTenantAndVillage(SessionHolder.getSysUser().getTenantId(), villageId);
            propertyChargeableListDtos.forEach(propertyChargeableListDto -> {
                headers.add(propertyChargeableListDto.getName() + DUE_DATE_EXAMPLE);
            });
            villageDto = villageService.selectCacheById(villageId);
        } else {
            //查询所有的收费标准
            List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByBuildingId(buildingId);
            propertyChargeableListDtos.forEach(propertyChargeableListDto -> {
                headers.add(propertyChargeableListDto.getName() + DUE_DATE_EXAMPLE);
            });
            villageBuildingDto = villageBuildingService.selectCacheById(buildingId);
            villageDto = villageService.selectCacheById(villageBuildingDto.getVillageId());
        }
        List<String[]> dataList = new ArrayList<>();
        String[] item = new String[headers.size()];

        item[0] = villageDto!=null? villageDto.getName():"";
        item[1] = villageBuildingDto!=null ? villageBuildingDto.getName():"";
        dataList.add(item);

        POIUtils.exportExcel(hresp, "收费标准过期日期导入模板", headers.toArray(new String[0]), dataList, "收费标准过期日期导入模板");

    }

    /**
     * 查询房间收费标准对应的截止日期
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("roomList")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:list")
    @Operation(summary = "查询房间收费标准对应的截止日期")
    public Response<Page<PropertyRoomChargeableListDueDateDto>> roomList(
            @Parameter(description = "从1开始的页码数") @RequestParam Integer pageNo,
            @Parameter(description = "每页多少条") @RequestParam Integer pageSize) {
        //查询列表数据
        Request request = Request.configParams(Request.parseParams(httpServletRequest));

        super.fillAuthorityData(request.getParams());
        int total = villageRoomService.queryTotal(request.getParams());

        List<PropertyRoomChargeableListDueDateDto> roomChargeableListDueDateDtos = new ArrayList<>();

        if (total > 0) {
            List<VillageRoomDto> villageRoomDtos = villageRoomService.queryList(request.getParams());

            //查询所有的收费标注 楼栋 ->list<收费标准>
            Set<Long> collect = villageRoomDtos.stream().map(VillageRoomDto::getBuildingId).collect(Collectors.toSet());
            Map<Long, List<PropertyChargeableListDto>> longListMap = new HashMap<>();
            for (Long aLong : collect) {
                //查询楼栋绑定的收费标准
                List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByBuildingId(aLong);
                longListMap.put(aLong, propertyChargeableListDtos);
            }

            for (VillageRoomDto villageRoomDto : villageRoomDtos) {
                PropertyRoomChargeableListDueDateDto dto = packByVillageRoom(villageRoomDto);

                Map<String, Object> params = new HashMap<>(8);
                params.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getTenantId), villageRoomDto.getTenantId());
                params.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getVillageId), villageRoomDto.getVillageId());
                params.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getRoomId), villageRoomDto.getId());
                //过期时间筛选
                params.put(PropertyBillConstants.DUE_DATE_SLOT_KEY_PAIR.getLeft(), request.getParams().get((PropertyBillConstants.DUE_DATE_SLOT_KEY_PAIR.getLeft())));
                params.put(PropertyBillConstants.DUE_DATE_SLOT_KEY_PAIR.getRight(), request.getParams().get((PropertyBillConstants.DUE_DATE_SLOT_KEY_PAIR.getRight())));
                List<PropertyChargeableListDueDateDto> propertyChargeableListDueDateDtos = propertyChargeableListDueDateService.queryList(params);
                //整合所有的list
                List<PropertyChargeableListDueDateDto> dueDateList = getAllChargeableListDueDate(longListMap.get(villageRoomDto.getBuildingId()), propertyChargeableListDueDateDtos);

                dto.setDueDateList(dueDateList);
                roomChargeableListDueDateDtos.add(dto);
            }
        }

        Page<PropertyRoomChargeableListDueDateDto> page = new Page<>(request.getPageNo(), request.getPageSize(), total, roomChargeableListDueDateDtos);
        return Response.<Page<PropertyRoomChargeableListDueDateDto>>ok().wrap(page);
    }

    /**
     * 整合收费标准和已经导入的收费标准,如果没有逾期时间和导入时间,则对应的时间为空
     *
     * @param propertyChargeableListDtos        所有的收费标准
     * @param propertyChargeableListDueDateDtos 房间所有的逾期时间列表
     * @return
     */
    private List<PropertyChargeableListDueDateDto> getAllChargeableListDueDate(List<PropertyChargeableListDto> propertyChargeableListDtos, List<PropertyChargeableListDueDateDto> propertyChargeableListDueDateDtos) {
        //新建list
        List<PropertyChargeableListDueDateDto> resultList = new ArrayList<>(propertyChargeableListDtos.size());
        //转换为map
        Map<Long, PropertyChargeableListDueDateDto> collect = propertyChargeableListDueDateDtos.stream().collect(Collectors.toMap(PropertyChargeableListDueDateDto::getChargeableListId, Function.identity(), (key1, key2) -> key2));
        //遍历
        for (PropertyChargeableListDto propertyChargeableListDto : propertyChargeableListDtos) {
            PropertyChargeableListDueDateDto dueDateDto = collect.get(propertyChargeableListDto.getId());
            if (dueDateDto == null) {
                PropertyChargeableListDueDateDto dto = new PropertyChargeableListDueDateDto();
                dto.setChargeableListId(propertyChargeableListDto.getId());
                dto.setChargeableListName(propertyChargeableListDto.getName());
                dto.setChargeableListDto(propertyChargeableListDto);
                resultList.add(dto);
            } else {
                resultList.add(dueDateDto);
            }
        }
        return resultList;

    }


    /**
     * 查询房间所有的收费标准过期列表,编辑查询反显
     *
     * @param id
     * @return
     */
    @GetMapping("infoForEdit/{id}")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:edit")
    @Operation(summary = "查询房间所有的收费标准过期列表,编辑查询反显")
    public Response<PropertyRoomChargeableListDueDateDto> infoForEdit(@PathVariable("id") Long id) {

        Map<String, Object> params = new HashMap<>();
        super.fillAuthorityData(params);
        params.put(SystemConstants.ENTITY_ID_FLAG, String.valueOf(id));
        if (villageRoomService.queryTotal(params) <= 0) {
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }

        VillageRoomDto villageRoomDto = villageRoomService.selectById(id);
        PropertyRoomChargeableListDueDateDto roomChargeableListDueDateDto = packByVillageRoom(villageRoomDto);

        //查询所有的收费标准,遍历所有的收费标准,然后将所有的收费标准返回
        List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByBuildingId(villageRoomDto.getBuildingId());
        //如果没有收费标准,直接返回
        if (CollectionUtils.isEmpty(propertyChargeableListDtos)) {
            return Response.<PropertyRoomChargeableListDueDateDto>ok().wrap(roomChargeableListDueDateDto);
        }
        //查询所有的收费标准
        Map<String, Object> dueDateParams = new HashMap<>(8);
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getTenantId), villageRoomDto.getTenantId());
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getVillageId), villageRoomDto.getVillageId());
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getRoomId), villageRoomDto.getId());
        //查询所有的过期时间
        List<PropertyChargeableListDueDateDto> propertyChargeableListDueDateDtos = propertyChargeableListDueDateService.queryList(dueDateParams);

        List<PropertyChargeableListDueDateDto> allChargeableListDueDate = getAllChargeableListDueDate(propertyChargeableListDtos, propertyChargeableListDueDateDtos);
        roomChargeableListDueDateDto.setDueDateList(allChargeableListDueDate);

        return Response.<PropertyRoomChargeableListDueDateDto>ok().wrap(roomChargeableListDueDateDto);
    }

    /**
     * 查询房间所有的收费标准过期列表
     *
     * @param id
     * @return
     */
    @GetMapping("info/{id}")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:info")
    @Operation(summary = "查询房间所有的收费标准过期列表")
    public Response<PropertyRoomChargeableListDueDateDto> info(@PathVariable("id") Long id) {

        Map<String, Object> params = new HashMap<>();
        super.fillAuthorityData(params);
        params.put(SystemConstants.ENTITY_ID_FLAG, String.valueOf(id));
        if (villageRoomService.queryTotal(params) <= 0) {
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }

        VillageRoomDto villageRoomDto = villageRoomService.selectById(id);
        PropertyRoomChargeableListDueDateDto roomChargeableListDueDateDto = packByVillageRoom(villageRoomDto);

        //查询所有的收费标准,遍历所有的收费标准,然后将所有的收费标准返回
        List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByBuildingId(villageRoomDto.getBuildingId());
        //如果没有收费标准,直接返回
        if (CollectionUtils.isEmpty(propertyChargeableListDtos)) {
            return Response.<PropertyRoomChargeableListDueDateDto>ok().wrap(roomChargeableListDueDateDto);
        }
        //查询所有的收费标准
        Map<String, Object> dueDateParams = new HashMap<>(8);
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getTenantId), villageRoomDto.getTenantId());
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getVillageId), villageRoomDto.getVillageId());
        dueDateParams.put(LambdaUtil.getFieldName(PropertyChargeableListDueDateDto::getRoomId), villageRoomDto.getId());
        //查询所有的过期时间
        List<PropertyChargeableListDueDateDto> propertyChargeableListDueDateDtos = propertyChargeableListDueDateService.queryList(dueDateParams);

        List<PropertyChargeableListDueDateDto> allChargeableListDueDate = getAllChargeableListDueDate(propertyChargeableListDtos, propertyChargeableListDueDateDtos);
        roomChargeableListDueDateDto.setDueDateList(allChargeableListDueDate);

        return Response.<PropertyRoomChargeableListDueDateDto>ok().wrap(roomChargeableListDueDateDto);
    }

    /**
     * 更新房间收费标准到期记录
     *
     * @param roomChargeableListDueDateDto
     * @return
     */
    @PostMapping("update")
    @RequirePermissions(values = "propertyRoomChargeableListDueDate:edit")
    @Operation(summary = "更新房间收费标准到期记录")
    public Response<PropertyRoomChargeableListDueDateDto> update(@RequestBody PropertyRoomChargeableListDueDateDto roomChargeableListDueDateDto) {

        Map<String, Object> params = new HashMap<>();
        super.fillAuthorityData(params);
        params.put(SystemConstants.ENTITY_ID_FLAG, String.valueOf(roomChargeableListDueDateDto.getId()));
        if (villageRoomService.queryTotal(params) <= 0) {
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }

        VillageRoomDto villageRoomDto = villageRoomService.selectById(roomChargeableListDueDateDto.getId());
        if (villageRoomDto == null) {
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }

        if (CollectionUtils.isEmpty(roomChargeableListDueDateDto.getDueDateList())) {
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }
        //更新对应的标准
        //查询所有的收费标准,遍历所有的收费标准,然后将所有的收费标准返回
        List<PropertyChargeableListDto> propertyChargeableListDtos = propertyChargeableListService.selectByBuildingId(villageRoomDto.getBuildingId());
        Map<Long, PropertyChargeableListDto> collect = propertyChargeableListDtos.stream().collect(Collectors.toMap(PropertyChargeableListDto::getId, Function.identity(), (key1, key2) -> key2));
        //遍历更新
        for (PropertyChargeableListDueDateDto propertyChargeableListDueDateDto : roomChargeableListDueDateDto.getDueDateList()) {
            //如果该收费标准不在该房间的范围内则不允许更新
            if (collect.get(propertyChargeableListDueDateDto.getChargeableListId()) == null || propertyChargeableListDueDateDto.getDueDate() == null) {
                continue;
            }
            propertyChargeableListDueDateDto.setImportTime(new Date());
            //查询数据库中的数据
            PropertyChargeableListDueDateDto dbDto = propertyChargeableListDueDateService.selectByRoomInfoAndListId(villageRoomDto.getTenantId(), villageRoomDto.getVillageId(), villageRoomDto.getId(), propertyChargeableListDueDateDto.getChargeableListId());
            //如果不存在 则需要新增
            if (dbDto == null) {
                propertyChargeableListDueDateDto.setTenantId(villageRoomDto.getTenantId());
                propertyChargeableListDueDateDto.setVillageId(villageRoomDto.getVillageId());
                propertyChargeableListDueDateDto.setRoomId(villageRoomDto.getId());
                propertyChargeableListDueDateService.save(propertyChargeableListDueDateDto);
            } else {
                propertyChargeableListDueDateService.updateById(propertyChargeableListDueDateDto);
            }
        }

        return Response.ok();
    }

    /**
     * 根据房间打包房间收费标准过期列表Dto
     *
     * @param roomDto
     * @return
     */

    private PropertyRoomChargeableListDueDateDto packByVillageRoom(VillageRoomDto roomDto) {
        PropertyRoomChargeableListDueDateDto dto = new PropertyRoomChargeableListDueDateDto();
        dto.setTenantId(roomDto.getTenantId());
        dto.setVillageId(roomDto.getVillageId());
        dto.setVillageName(roomDto.getVillageName());
        dto.setId(roomDto.getId());
        dto.setBuildingName(roomDto.getBuildingName());
        dto.setFloorName(roomDto.getFloorName());
        dto.setRoomName(roomDto.getName());
        dto.setVillageRoom(roomDto);
        return dto;
    }


}
